<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
    :editor-items="editorItems"
    page-type="commonPage"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'base/user/user/agentuser',
      // Web路径
      webPath: 'base/user/user/agent_user',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "name",
              name: "门店编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "sexSign",
              name: "性别标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                options: [
                  { key: "1", value: "男" },
                  { key: "2", value: "女" }
                ]
              }
            },
            {
              code: "stateSign",
              name: "状态标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                options: [
                  { key: "1", value: "未审核" },
                  { key: "2", value: "已审核" }
                ]
              }
            },
            {
              code: "baseUserCode",
              name: "基础用户编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "baseUserName",
              name: "基础用户名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "code",
          name: "编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "name",
          name: "门店编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "phone",
          name: "联系电话",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "imgPath",
          name: "头像地址",
          type: "oss",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "sexSign",
          name: "状态标识",
          type: "select",
          span: 6,
          config: {
            edit: false,
            options: [
              { key: "1", value: "男" },
              { key: "2", value: "女" }
            ]
          }
        },
        {
          code: "content",
          name: "人员介绍",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "stateSign",
          name: "状态标识",
          type: "select",
          span: 6,
          config: {
            edit: false,
            options: [
              { key: "1", value: "未审核" },
              { key: "2", value: "已审核" }
            ]
          }
        },
        {
          code: "baseUserCode",
          name: "基础用户编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "baseUserName",
          name: "基础用户名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "agentCode",
          name: "代理商编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "agentName",
          name: "代理商名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false,
                rules: [
                  { required: true, message: '请输入编码', trigger: 'blur' }
                ]
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                rules: [
                  { required: true, message: '请输入名称', trigger: 'blur' }
                ]
              }
            },
            {
              code: "phone",
              name: "联系电话",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "imgPath",
              name: "头像地址",
              type: "oss",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "sexSign",
              name: "状态标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                options: [
                  { key: "1", value: "男" },
                  { key: "2", value: "女" }
                ]
              }
            },
            {
              code: "stateSign",
              name: "状态标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                options: [
                  { key: "1", value: "未审核" },
                  { key: "2", value: "已审核" }
                ]
              }
            },
            {
              code: "content",
              name: "人员介绍",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "baseUserCode",
              name: "基础用户编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "baseUserName",
              name: "基础用户名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "agentCode",
              name: "代理商编码",
              type: "popup",
              span: 6,
              config: {
                edit: false,
                url: "base/user/user/agent",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                rules: [
                  { required: true, message: '请选择代理商', trigger: 'blur' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("agentName", row.name)
                  this.$refs.commonPage.updateFormData("agentId", row.id)
                }
              }
            },
            {
              code: "agentName",
              name: "代理商名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            }
          ]
        }
      ],
      // 富文本编辑器内容
      editorItems: [
        {
          key: "content",
          name: "人员介绍"
        }
      ]
    }
  }
}
</script>
